package model.dto;

import java.util.ArrayList;
import model.Spot;
import db.DAOFactory;

public class Sight {
	private int id;
	private String name;
	private String description;
	private int price;
	private String url;
	private int userId;
	private ArrayList<Spot> index;
	private ArrayList<Spot> spots;

	public Sight(String sightName) {
		Spot self = DAOFactory.getSpotDAO().findByName(sightName);
		
		id = self.getId();
		name = self.getName();
		description = self.getDescription();
		price = self.getPrice();
		url = self.getUrl();
		userId = self.getOwnerId();
		spots = DAOFactory.getSpotDAO().findBySightId(id);
		
		index = new ArrayList<Spot>();
		findParents(self);
	}
	
	private void findParents(Spot spot) {
		if(spot != null){
			Spot parent = spot.getSight();
			if(parent != null){
				index.add(parent);
				findParents(parent);
			}
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getPrice() {
		return price;
	}

	public void setPrice(int price) {
		this.price = price;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public ArrayList<Spot> getIndex() {
		return index;
	}

	public void setIndex(ArrayList<Spot> index) {
		this.index = index;
	}

	public ArrayList<Spot> getSpots() {
		return spots;
	}

	public void setSpots(ArrayList<Spot> spots) {
		this.spots = spots;
	}

}
